#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define STDIN
//#define DEBUG

#define MAX_MSG_LEN 101

char original_msg[MAX_MSG_LEN];
int  om_letter_statics[26] = {0};
char engraved_msg[MAX_MSG_LEN];
int  em_letter_statics[26] = {0};

int compare(const void* a, const void* b)
{
	return *(int*)a - *(int*)b;
}

int main()
{
#ifdef STDIN
	freopen("bin/2159.in", "r", stdin);
#endif

	scanf("%s", engraved_msg);
	scanf("%s", original_msg);

	if (strlen(engraved_msg) != strlen(original_msg))
	{
		printf("NO\n");
		return 0;
	}

	int i;
	int len = strlen(engraved_msg);
	char om_ch, em_ch;
	for (i = 0; i < len; ++i)
	{
		om_ch = original_msg[i];
		om_letter_statics[om_ch - 'A']++;
		em_ch = engraved_msg[i];
		em_letter_statics[em_ch - 'A']++;
	}

	qsort(om_letter_statics, 26, sizeof(om_letter_statics[0]), compare);
	qsort(em_letter_statics, 26, sizeof(em_letter_statics[0]), compare);

	int conjecture = 1;
	for (i = 0; i < 26; ++i)
	{
		if (om_letter_statics[i] != em_letter_statics[i])
		{
			conjecture = 0;
			break;
		}


	}
	if (conjecture == 0)
		printf("NO\n");
	else
		printf("YES\n");

	return 0;
}
